<?php
include("class.phpmailer.php");
//Available Template: templateRequest, templateSchoolConfirm
function templateRequest($eventID,$volunteerID) {
    $event_id = $eventID;
    $volunteer_id = $volunteerID;
    $template = Array();
//retrieve data
//event name
    $query1 = "SELECT event_name FROM event WHERE event_id = $event_id";
    $event_a = executeSelectQuery($query1);
    $event_name=$event_a[0]['event_name'];
//
    $query2 = "SELECT * FROM session WHERE event_id = $event_id";
    $session_array = executeSelectQuery($query2);
    $first = $last = $session_array[0]['session_date'];
    for ($m=0;$m<count($session_array);$m++) {
        if ($session_array[$m]['session_date']<$first) {
            $first = $session_array[$m]['session_date'];
        }
        if ($session_array[$m]['session_date']>$last) {
            $last = $session_array[$m]['session_date'];
        }
    }
//
    $query3 = "SELECT volunteer_salutation, volunteer_firstname, volunteer_surname FROM volunteer WHERE volunteer_id = $volunteer_id";
    $volunteer_a = executeSelectQuery($query3);
    $volunteer_name = $volunteer_a[0]['volunteer_salutation']." ".$volunteer_a[0]['volunteer_firstname']." ".$volunteer_a[0]['volunteer_surname'];
//Email content
    $template['title'] = "Be trainer for new JA event: $event_name";
    $template['content'] = <<<HERE
Dear $volunteer_name,

You have been matched to be a volunteer for our upcoming course: 291111-JA Be Entrepreneurial-Hougang Primary School.
The course will start from $first and end on $last.

For more information and to indicate your interest, login now at http://scheduler.ja.org.sg/volunteer/event/volunteerRequestList.php

We are looking forward to hearing from you,

Thank you for your support of JA Programs.

Best regards,
Ng. Hau Yee (Ms.)
Director
Junior Achievement Singapore


* It is an auto-generated email. Please do not reply
Any question, please email hauyee.ng@ja.org
HERE;
    return $template;
}
//
//
//
function templateSchoolConfirm($contact_id,$event_id) {
    $template=Array();
    $cid = $contact_id;
    $eid = event_id;
    //get data
    $query1 = "SELECT event_name FROM event WHERE event_id = $eid";
    $event_a = executeSelectQuery($query1);
    $event_name=$event_a[0]['event_name'];
    //
    $query2 = "SELECT * FROM contact_school WHERE contact_school_id  = $cid";
    $contact_a = executeSelectQuery($query2);
    $contact_name = $contact_a[0]['contact_salutation']." ".$contact_a[0]['contact_name'];
    // Now is the email
    $template['title'] = "Congratulations! Course $event_name is now confirmed.";
    $template['content'] = <<<HERE
Dear $contact_name,

Congratulations! Course $event_name is now confirmed.

For more information, please login at http://scheduler.ja.org.sg/

Thank you for your support of JA Programs.

Best regards,
Ng. Hau Yee (Ms.)
Director
Junior Achievement Singapore


* It is an auto-generated email. Please do not reply
Any question, please email hauyee.ng@ja.org
HERE;
    return $template;
}
?>